<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
   <% String path=request.getContextPath();
   String basePath=request.getScheme()
    + "://" + request.getServerName() + ":" + request.getServerPort() + path
    + "/";

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="<%=basePath%>">
<title>极速出单销售管理配置</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp"></jsp:include>
<link rel="stylesheet" href="<%=path%>/css/zTreeStyle/zTreeStyle.css">
<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
<style type="text/css">
#saveAppTable tr td{border-bottom:1px solid #A4BDE3;}
.inputborder{border-color: #ec8181;}
.xxDialog{
	margin-left: -20% !important;
}
div.xxDialog .dialogClose {
	width: 0;
}
</style>
<script>
//自定义map功能
function Map(){
  this.elements = new Array();
   //获取MAP元素个数
   this.size = function() {
       return this.elements.length;
   };
   //判断MAP是否为空
   this.isEmpty = function() {
       return (this.elements.length < 1);
   };
   //删除MAP所有元素
   this.clear = function() {
       this.elements = new Array();
   };
   //向MAP中增加元素（key, value)
   this.put = function(_key, _value) {
       if(this.containsKey(_key)){
        this.remove(_key);
        this.elements.push( {
           key : _key,
           value : _value
        });
       }else{
        this.elements.push( {
           key : _key,
           value : _value
        });
       }
   };
   //删除指定KEY的元素，成功返回True，失败返回False
   this.remove = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   this.elements.splice(i, 1);
                   return true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
   //获取指定KEY的元素值VALUE，失败返回NULL
   this.get = function(_key) {
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   return this.elements[i].value;
               }
           }
       } catch (e) {
           return false;
       }
       return false;
   };
   //判断MAP中是否含有指定KEY的元素
   this.containsKey = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   bln = true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
  //获取map的所有values
  this.values = function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].value);
       }
       return arr;
   };
  //获取map的所有keys
  this.keys= function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].key);
       }
       return arr;
   };
   //获取数组
   this.getArray= function(){
   	var arr = new Array();
   	for (var i = 0; i < this.elements.length; i++) {
           arr.push({
	            key : this.elements[i].key,
	            value : this.elements[i].value
	         });
       }
       return arr;
   };
}
var rolemap=new Map();
var arr=null;
var arr1 = new Array();
/**清空数据**/
function reserv(){
	$("#deptCode_div").val('');
	$("#agentNo_div").val('');
	$("#protocolNo_div").val('');
	$("#PERMITNOB").val('');
	$("#serviceCode_div").val('');
	$("#serviceName_div").val('');
	$("#empNo_div").val('');
	$("#empName_div").val('');
	$("#teamCode_div").val('');
	$("#teamName_div").val('');
	$('#channelCodeQD').val('');
	$('#channelType').val('');
	$('#newBsnsType').val('');
	$('#bsnsType').val('');
	$("#cbrkrname_div").val('');
	$("#pro_key1").val('');
	$("#pro_key2").val('');
	$("#pro_key3").val('');
	$("#pro_key4").val('');
	$("#pro_key5").val('');
}
function saveAgentMtInfo(){
	var agentType = $.trim($("#agentType_div").val());
	var dptCde = $.trim($("#deptCode_div").val());
	var channelCode = $.trim($("#partnerCode_div").val());
	var agentNo = $.trim($("#agentNo_div").val());
	var protocolNo = $.trim($("#protocolNo_div").val());
	var cAgentSlsCde = $.trim($("#PERMITNOB").val());
	var serviceCode = $.trim($("#serviceCode_div").val());
	var serviceName = $.trim($("#serviceName_div").val());
	var empNo = $.trim($("#empNo_div").val());
	var empName = $.trim($("#empName_div").val());
	var teamCode = $.trim($("#teamCode_div").val());
	var teamName = $.trim($("#teamName_div").val());
/* 	var cardApplicant = $.trim($("#cardApplicant_div").val()); */
	var channle_code = $.trim($('#channelCodeQD').val());
	var channle_type = $.trim($('#channelType').val());
	var newBsns = $.trim($('#newBsnsType').val());
	var categoryCode = $.trim($('#bsnsType').val());
	var cbrkrname = $.trim($("#cbrkrname_div").val());
/* 	var coprcod = $.trim($("#coprcod_div").val()); */
	var key1 = $.trim($("#pro_key1").val());
	var key2 = $.trim($("#pro_key2").val());
	var key3 = $.trim($("#pro_key3").val());
	var key4 = $.trim($("#pro_key4").val());
	var key5 = $.trim($("#pro_key5").val());
	var productType = $.trim($("#productType").val());
	var agentInfoId = $('#agentInfoId').val();
	var prodSet = $.trim($("#prodSet").val());
	var realChannel = $('#realChannels').val();
	if(key1.length==0){
		$.message("error","请输入key1值");
		return;
	}
	if(key2.length==0){
		$.message("error","请输入key2值");
		return;
	}
/* 	if(key3.length==0){
		$.message("error","请输入key3值");
		return;
	}
	if(key4.length==0){
		$.message("error","请输入key4值");
		return;
	}
	if(key5.length==0){
		$.message("error","请输入key5值");
		return;
	} */
	if(agentType.length == 0){
		$.message("error", "请选择销售类型");
		return;
	}
	if(channelCode.length == 0){
		$.message("error", "请传入合作伙伴代码");
		return;
	}
	if(dptCde.length == 0){
		$.message("error", "请选择出单机构");
		return;
	}

	if(channle_code.length==0){
		$.message("error", "请选择归属渠道");
		$('#channelCodeQD').focus();
		return;
	}

	if(channle_type.length==0){
		$.message("error", "请选择渠道类型");
		$('#channelType').focus();
		return;
	}

	if(newBsns.length==0){
		$.message("error", "请选择新业务来源");
		$('#newBsnsType').focus();
		return;
	}

	if(categoryCode.length==0){
		$.message("error", "请选择原业务来源");
		$('#bsnsType').focus();
		return;
	}
	if(categoryCode=="19002"||categoryCode=="19003"){
		if(agentNo.length == 0){
			$.message("error", "请输入代理人编码");
			return;
		}else if(protocolNo.length == 0){
			$.message("error", "请输入代理人协议号");
			return;
		}else if(cbrkrname.length == 0){
			$.message("error", "请输入代理人名称");
			return;
		}
	}
	if(serviceCode.length == 0){
		if(agentType == '5'){
			keyAddClass("serviceCode_div");
		}
		$.message("error", "请输入服务代码");
		return;
	}
	if(serviceName.length==0){
		$.message("error", "请输入服务名称");
		return;
	}
	if(empNo.length == 0){
		if(agentType == '5'){
			keyAddClass("empNo_div");
		}
		$.message("error", "请输入业务员代码");
		return;
	}
	if(empName.length==0){
		$.message("error", "请输入业务员名称");
		return;
	}
	if(teamCode.length == 0){
		if(agentType == '5'){
			keyAddClass("teamCode_div");
		}
		$.message("error", "请输入团队代码");
		return;
	}
	if(teamName.length == 0){
		if(agentType == '5'){
			keyAddClass("teamName_div");
		}
		$.message("error", "请输入团队名称");
		return;
	}
	if(!productType || productType.length==0){
		$.message("error", "请选择销售落地数据对应的产品类型");
		return;
	}
	if("true" ==$("#ishave").val()){
		arr='';
	}
/* 	//销售类型是联合出单:key1~key5校验
	if(agentType == '5'){
		var primeKey = checkKey(key1,key2,key3,key4,key5);
		if(!primeKey) return;
	} */
	$.openLoading();
	$.ajax({
		url : "<%=path%>/extend/saveAgentMtInfo?"+new Date().getTime(),
		type : 'POST',
		async : true,
		data:{
			agentType:agentType,
		 	channelCode:channelCode,
			dptCde:dptCde,
			agentNo:agentNo,
			protocolNo:protocolNo,
			cAgentSlsCde:cAgentSlsCde,
			serviceCode:serviceCode,
			serviceName:serviceName,
			empNo:empNo,
			empName:empName,
			teamCode:teamCode,
			teamName:teamName,
			channleCode:channle_code,
			channleType:channle_type,
			newBsnsType:newBsns,
			categoryCode:categoryCode,
			cbrkrname:cbrkrname,
			key1:key1,
			key2:key2,
			key3:key3,
			key4:key4,
			key5:key5,
			productType:productType,
			saleArry:arr,
			prodSet:prodSet,
			realChannel:realChannel
		},
		dataType:'json',
		success : function(data) {
			$.closeLoading();
			if('error' == data.result && ''!= data.message){
				if('销管校验异常' == data.message.substring(0,6)){
					var title ="与销管系统交互校验不通过，是否清除异常数据"
					if(agentInfoId){
						$.dialog({
							type: "warn",//success,error
							content: title,
							onOk: function() {
								$.openLoading();
								$.ajax({
									url : "<%=path%>/extend/deleteAgentMtInfoById?"+new Date().getTime(),
									type : 'POST',
									async: true,
									dataType:'json',
									data:{
										id:agentInfoId,
									},
									success : function(data) {
										$.closeLoading();
										if($.validate(data)) return;
										reserv();
									}
								});
							}
						});
					}else {
						$.message("error",data.message );
					}
					return;
				}else {
					$.message("error", data.message);
					return;
				}
			}
			if ("fail"==data.result){
				$.message("error", "系统错误,请联系管理员");
				return;
			}
			if("success"==data.result&&""!=data.message){
				$.message("success", data.message);
			}
			reserv();
			empInfoWrite();
			teamInfoWrite();
		}
	});
}
//为空输入框提示
function keyAddClass(keyId){
	var key = $("#"+keyId);
	var keyf = key.parent();
	key.addClass("inputborder");
	key.one("focus",function(){
		key.removeClass("inputborder");
	});
}

$(document).ready(function(){
	chooseProdType();
	//归属渠道
	$("#channelCodeQD").change(function(){
		var channelCodeQD = $("#channelCodeQD").val();
		var channelType = $("#channelType").val();
		subDropDownList("channel_type",channelCodeQD,"channelType",);
		// subDropDownList("new_business_source","","newBsnsType");
		$("#channelType").val(channelType);

	});
	$("#channelCodeQD").change();
	//渠道类型
	$("#channelType").change(function(){
		var newBsnsType = $('#newBsnsType').val();
		var channelType = $("#channelType").val();
		subDropDownList("new_business_source",channelType,"newBsnsType");
		$('#newBsnsType').val(newBsnsType);
	});
	$("#channelType").change();
	//新业务来源
	$("#newBsnsType").change(function(){
		var parentCode = $("#channelType").val();
		var newBsnsCode = $("#newBsnsType").val();
		$("#unauthorizedProducts").empty();
		chooseBsnsType(parentCode,newBsnsCode);
		if ($("#bsnsType").val() != '19001'){
			queryAgentAndAgreeInfo();

			$("#unauthorizedProducts_select").show();
		}else{
			$('#agentNo_select').empty();
			$('#agentNo_div').val('');
			$('#cbrkrname_div').val('');
			$('#protocolNo_div').val('');
			$('#PERMITNOB').val('');
			$("#unauthorizedProducts_select").hide();
			$('#agentNo_select').attr("disabled", true).css('background-color','#ccc');
			queryServiceNo();
		}
	});
	//旧业务来源
	$("#bsnsType").change(function(){
		var newBsnsCode = $("#newBsnsType").val();
		var bsnsTypeCode = $("#bsnsType").val();
		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		if(bsnsTypeCode!="19002"&&bsnsTypeCode!="19003"){
			$("#agentNo_div ~ span").remove(".red");
			$("#cbrkrname_div ~ span").remove(".red");
			$("#protocolNo_div ~ span").remove(".red");
		}else{
			if($("#agentNo_div ~ span").length==0){
				$("#agentNo_div").parent().append("<span class='red'>*</span>");
			}
			if($("#cbrkrname_div ~ span").length==0){
				$("#cbrkrname_div").parent().append("<span class='red'>*</span>");
			}
			if($("#protocolNo_div ~ span").length==0){
				$("#protocolNo_div").parent().append("<span class='red'>*</span>");
			}
		}
	});
	var deptCode = $('#deptCode_div').val();
	if( deptCode !='' && deptCode != 'null')
	if(deptCode.substring(0,2) == '44'){
		$("#saleInfoConfigId").attr("disabled", false);
	}else{
		$("#saleInfoConfigId").attr("disabled", true);
	}
	querySauserAndTeamInfo('');
	var newBsns=$('#newBsnsType').val();
	if(newBsns!=''){
		var channelCodeQD=newBsns.substring(0,1);
		var channelType=newBsns.substring(0,3);
		$('#channelCodeQD').val(channelCodeQD);
		$('#channelType').val(channelType);
		var parentCode = $("#channelType").val();
		var newBsnsCode = $("#newBsnsType").val();
		chooseBsnsType(parentCode,newBsnsCode,1);
	}
	if($("#ishave").val()){
		//$.message("success", "合作伙伴已存在销售渠渠道信息");
	}
});
//选择旧业务来源
function chooseBsnsType(parentCode,newBsnsCode,initflag){
	$.ajax({
		url : "<%=path%>/extend/chooseBsnsType",
		type : 'POST',
		async : false,
		data:{parentCode:parentCode,newBsnsCode:newBsnsCode},
		dataType:'json',
		success:function(data){
				if($.validate(data))  return;
				if (data != null) {
					$("#bsnsType").val(data.otherCode);
					//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
					if(data.otherCode=="19002"||data.otherCode=="19003"){
						if($("#agentNo_div ~ span").length==0){
							$("#agentNo_div").parent().append("<span class='red'>*</span>");
						}
						if($("#cbrkrname_div ~ span").length==0){
							$("#cbrkrname_div").parent().append("<span class='red'>*</span>");
						}
						if($("#protocolNo_div ~ span").length==0){
							$("#protocolNo_div").parent().append("<span class='red'>*</span>");
						}
					}else{
						if(initflag!=1){
							$('#agentNo_div').val('');
							$('#cbrkrname_div').val('');
							$('#protocolNo_div').val('');
							$('#PERMITNOB').val('');
						}
						$("#agentNo_div ~ span").remove(".red");
						$("#cbrkrname_div ~ span").remove(".red");
						$("#protocolNo_div ~ span").remove(".red");
					}
				}
       	}
	});
}
//下拉框处理
function subDropDownList(codeType,element1,element2,element3){
	$.ajax({
		url : "<%=path%>/extend/loadSubDropList",
		type : 'POST',
		async : false,
		data:{codeType:codeType,parentCode:element1},
		dataType:'json',
		success:function(appList){
			if($.validate(appList))  return;
			var appSelect = document.getElementById(element2);
			appSelect.options.length = 0;
			if (appList != null) {
				for (var i = 0; i < appList.length; i++) {
					var option = new Option();
					option.text = appList[i].codeName;
					option.value = appList[i].code;
					appSelect.add(option);
				}
			}
       	}
	});
}
//打开机构窗口
function openDeptDiv(pageIndex,obj){

	if($.trim($('#partnerCode_div').val()).length==0){
		$.message("error", "请先选择合作伙伴代码");
		return;
	}

	$('#deptcode').val('');
	$('#deptcnname').val('');
	$("#"+obj.id).blur();
	queryCoreDept1(pageIndex);
}
//调用拼接参数的方法，并执行查询
function queryCoreDept(pageIndex){
	var size = 8;
	var code = $('#deptcode').val();
	var name = $('#deptcnname').val();
	var pno = $('#partnerCode_div').val();
	queryAllDepts({size:size,pageIndex:pageIndex,deptCode:code,deptCNname:name,channelCode:pno});
}
function queryCoreDept1(pageIndex){
	var size = 8;
	var code = $('#pro_key1').val().substring(0,6);
	var name = $('#deptcnname').val();
	var pno = $('#partnerCode_div').val();
	queryAllDepts({size:size,pageIndex:pageIndex,deptCode:code,deptCNname:name,channelCode:pno});
}
//查询机构
function queryAllDepts(param){
	$("#BigDiv2").remove();
	$.openLoading();
	$.ajax({
		url : "extend/loadCoreDept",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(deptPage){
			$.closeLoading();
			if($.validate(deptPage))return;

					var radioObj ="<input class='input_fxk' name='deptradio' type='radio' value=''>";
					var fieldNames = "deptCode,deptCNname";
					var tableContent = creatTable1(fieldNames,deptPage,radioObj);
					var tableObj = $("#deptTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);

					var strPage = creatChannelPage3(param.pageIndex,6,deptPage.maxPage,"18");
					var pageDIV = $("#deptPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);

					$("#deptDiv").OpenDiv2();

					bindradio();
			}
	});
}
//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradio(){
	$("input[name='partnerradio']").click(function(){
		$("input[name='partnerradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='deptradio']").click(function(){
		$("input[name='deptradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='subChannelInforadio']").click(function(){
		$("input[name='subChannelInforadio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
}
//点击“确定” ，选择 出单机构
function chooseDept(){
	var selectedDept= $("input[name='deptradio']:checked");
	if(selectedDept.length==0){
		$.message("error", "请选择一个出单机构");
		return;
	}
	var deptCode = selectedDept.parent().parent().children(" td:eq(1)").html();
	if(deptCode.length != 8){
		$.message("error", "只能选择8位数出单机构");
		return;
	}
	$('#deptCode_div').val(deptCode);
	if(deptCode.substring(0,2) == '44'){
		$("#saleInfoConfigId").attr("disabled", false);
	}else{
		$("#saleInfoConfigId").attr("disabled", true);
	}
	closeCurrentDIV('deptDiv');
	querySauserAndTeamInfo('');
}

//代理人代码改变时，同步改变协议号
function changeAgentNo(){
	var agentNo_select = $.trim($("#agentNo_select").val());
		$("#agentNo_div").val(agentNo_select);

		if(agentNo_select.length==0){
			$("#protocolNo_div").val("");
			$("#PERMITNOB").val("");
			$("#cbrkrname_div").val("");
			serviceInfoWrite();
			return;
		}

		for (var i = 0; i < agent_agreement_list.length; i++) {
			var AGENTCODE = agent_agreement_list[i].AGENTCODE;
		if(agentNo_select == AGENTCODE){
			$("#protocolNo_div").val(agent_agreement_list[i].AGREEMENTNO);
			$("#cbrkrname_div").val(agent_agreement_list[i].AGENTNAME);
			$('#PERMITNOB').val(agent_agreement_list[i].PERMITNOB);
			break;
		}
	}
	queryServiceNo();
	queryUnauthorizedProducts();
}
//获取业务员信息及业务员所在团队信息
var team_user_list;//存放销管返回的业务员及团队信息的List,便于业务员代码改变时，业务员名称和团队列表的同步改变
function querySauserAndTeamInfo(tempTr){
	var dptCde = $.trim($('#deptCode_div').val());
	//必须先选择出单机构，再获取
	if(dptCde.length==0){
		$.message('error',"请先选择出单机构");
		return;
	}
	$.openLoading();
	$.ajax({
		url : "<%=path%>/extend/querySauserAndTeamInfo?"+new Date().getTime(),
		type : 'POST',
		async : true,
		data:{
			COMCODE:dptCde
		},
		dataType:'json',
		success:function(result){
			$.closeLoading();
			var select = document.getElementById("empNo_select");
			select.options.length = 0;
			select.add(new Option("-----请选择-----",""));
			team_user_list = result.data;
	 		var empNo = $.trim($("#empNo_div").val());
	 		if(null != team_user_list){
	 			for (var i = 0; i < team_user_list.length; i++) {
					var option = new Option();
					option.text = team_user_list[i].USERCODE + "-" + team_user_list[i].USERNAME;
					option.title = team_user_list[i].USERCODE + "-" + team_user_list[i].USERNAME;
					option.value = team_user_list[i].USERCODE;
					if(empNo == team_user_list[i].USERCODE){
						option.selected=true;
						$("#empName_div").val(team_user_list[i].USERNAME);
					}

					$('#empNo_select_div').css('display','inline').val("");
					$('#empNo_div').hide();
					select.add(option);
				}
	 		}
	 		 if('' != tempTr){
	 			var emoValList = $("#empNo_select option");
	 			var empNo = $('#empNo_div').val();
	 			var empName = $('#empName_div').val();
	 			var empFlag =false;
	 			for(var i = 0;i < emoValList.length;i++){
 					/* console.log(empNo+"-"+empName +"============"+ emoValList[i].title); */
	 				if(empNo+"-"+empName == emoValList[i].title){
	 					empFlag =true;
	 				}
	 			}
	 			/* console.log(empFlag); */
	 			if(empFlag){
	 				$("#empNo_select").val(empNo);
	 			}
	 			$("#empNo_div").val(empNo);
	 			$("#empName_div").val(empName);
	 		}
		}
	});
}

//业务员下拉框改变时，动态改变业务员名称和团队代码
var TEAMList;//存放当前所选业务员对应的团队List，便于团队代码改变时，团队名称的同步改变
function changeEmpNo(){
	var dptCde = $.trim($('#deptCode_div').val());
	var channleCode_QD = $.trim($('#channelCodeQD').val());
	var newBsnsType =$.trim($('#newBsnsType').val());
	//必须先选择出单机构、归属渠道、业务来源,再获取
	if(dptCde.length == 0){
		$("#empNo_select").find("option[value='']").attr("selected",true);
		$.message('error',"请选择出单机构");
		return;
	}
	$('#agentNo_div').val('');
	$('#cbrkrname_div').val('');
	$('#protocolNo_div').val('');
	$('#PERMITNOB').val('');
	// if(channleCode_QD.length == 0){
	// 	$("#empNo_select").find("option[value='']").attr("selected",true);
	// 	$.message('error',"请选择归属渠道");
	// 	return;
	// }
	// if(newBsnsType.length == 0){
	// 	$("#empNo_select").find("option[value='']").attr("selected",true);
	// 	$.message('error',"请选择业务来源");
	// 	return;
	// }
	var empNo_select = $.trim($("#empNo_select").val());
	// if (empNo_select.length > 10) {
	// 	$.message('error', "业务员代码长度不能超过10位！");
	// 	return;
	// }
	$("#empNo_div").val(empNo_select);
/*	if(empNo_select.length == 0) {
		$("#empName_div").val("");
		teamInfoWrite();
		agentInfoWrite();
		serviceInfoWrite();
		return;
	}*/
	if(null != team_user_list){
		for (var i = 0; i < team_user_list.length; i++) {
			var USERCODE = team_user_list[i].USERCODE;
			if(empNo_select == USERCODE){
				$("#empName_div").val(team_user_list[i].USERNAME);
				TEAMList = team_user_list[i].TEAMList;
				var select = document.getElementById("teamCode_select");
				select.options.length = 0;
				select.add(new Option("-----请选择-----",""));
				if(null != TEAMList){
					for (var j = 0; j < TEAMList.length; j++) {
						var option = new Option();
						option.text = TEAMList[j].TEAMCODE + "-" + TEAMList[j].TEAMNAME;
						option.title = TEAMList[j].TEAMCODE + "-" + TEAMList[j].TEAMNAME;
						option.value = TEAMList[j].TEAMCODE;
						select.add(option);
					}
				}
				teamInfoSelect();
				return;
			}
		}
	}
}
//服务代码改变时，同步改变服务名称
function changeServiceCode(){
	var serviceCode_select = $.trim($("#serviceCode_select").val());
		$("#serviceCode_div").val(serviceCode_select);

		if(serviceCode_select.length==0) {
			$("#serviceName_div").val("");
			return;
		}

		for (var i = 0; i < servicenos_list.length; i++) {
			var SERVICENO = servicenos_list[i].SERVICENO;
		if(serviceCode_select == SERVICENO){
			$("#serviceName_div").val(servicenos_list[i].SERVICENAME);
		}
		}
}
//服务代码、服务名称可输入状态
function serviceInfoWrite(){
	$('#serviceCode_select_div').css('display','none').val("");
	$('#serviceCode_div').show().val('');
	$('#serviceName_div').attr("readonly",false).css('background-color','white').val('');
}
//代理人代码、代理协议号可输入状态
function agentInfoWrite(){
	$('#agentNo_select_div').css('display','none').val("");
	$('#agentNo_div').show().val('');
	$('#protocolNo_div').attr("readonly",false).css('background-color','white').val('');
	$('#cbrkrname_div').attr("readonly",false).css('background-color','white').val('');
}
//团队代码改变时，动态改变团队名称
function changeTeamCode(){
	$('#realChannels').val("");
	var teamCode_select = $.trim($("#teamCode_select").val());
	var teamCode = $.trim($("#teamCode_div").val());
	if (teamCode_select.length > 11) {
		$.message('error', "团队代码长度长度不能超过11位！");
		return;
	}
	$("#teamCode_div").val(teamCode_select);
	if(teamCode_select.length==0) {
		$("#teamName_div").val("");
		return;
	}
	if(null != TEAMList){
		for (var i = 0; i < TEAMList.length; i++) {
			var TEAMCODE = TEAMList[i].TEAMCODE;
			if(teamCode_select == TEAMCODE){
				$("#teamName_div").val(TEAMList[i].TEAMNAME);
				if("G" == TEAMList[i].CHANNELNAME || "K" == TEAMList[i].CHANNELNAME){
					$('#realChannels').val(TEAMList[i].CHANNELNAME);
					$('#channelCodeQD').val("A");
				}else{
					$('#channelCodeQD').val(TEAMList[i].CHANNELNAME);
				}
				$('#channelCodeQD').change();
			}
			// queryAgentAndAgreeInfo();
		}
	}
}
//查询中介-协议信息
	var agent_agreement_list;//存放销管返回的代理人代码和协议号的List,便于代理人代码改变时，协议号的同步改变
function queryAgentAndAgreeInfo(){
		var prodSaleCode = 'A225';//1949产品销管代码
		var dptCde = $.trim($('#deptCode_div').val());
		var channleCode_QD = $.trim($('#channelCodeQD').val());
		var newBsnsType =$.trim($('#newBsnsType').val());
		var teamCode = $.trim($('#teamCode_div').val());
		var productType = $.trim($('#productType').val());
		var empNo = $('#empNo_select').val();
		if (empNo == ''){
			empNo = $('empNo_div').val();
		}
		console.log('业务员代码为：' + empNo);
	$.openLoading();
	$.ajax({
		url : "<%=path%>/extend/queryAgentAndAgreeInfo?"+new Date().getTime(),
		type : 'POST',
		async : false,
		data:{
			COMCODE:dptCde,
			TEAMCODE:teamCode,
			BUSINESSSOURCE:newBsnsType,
			CHANNELNAME:channleCode_QD,
			PRODCODE:prodSaleCode,
            productType:productType,
			empNo:empNo
		},
		dataType:'json',
		success:function(result){
			var select = document.getElementById("agentNo_select");
			select.options.length = 0;
			$.closeLoading();
			if("success"!=result.result) {
				$.message('error',result.message);
				return;
			}

			select.options.length = 0;
			select.add(new Option("-----请选择-----",""));
			agent_agreement_list = result.data;
			for (var i = 0; i < agent_agreement_list.length; i++) {
				var option = new Option();
				option.text = agent_agreement_list[i].AGENTCODE;
				option.title = agent_agreement_list[i].AGENTCODE;
				option.value = agent_agreement_list[i].AGENTCODE;
				select.add(option);
			}
			agentInfoSelect();
		}
	});
}
//代理人代码可选状态
function agentInfoSelect(){
	$('#agentNo_select_div').css('display','inline').val("");
	$('#agentNo_div').hide().val('');
	$('#protocolNo').attr("readonly",true).css('background-color','#ccc').val("");
	$('#agentName').attr("readonly",true).css('background-color','#ccc').val("");
}
//查询服务代码信息
var servicenos_list;//存放销管返回的服务代码和服务名称的List,便于服务代码改变时，服务名称的同步改变
function queryServiceNo(){
	//G、K渠道默认A渠道，使用服务代码：0000Z1999999
	if("" != $('#realChannels').val()){
		$('#serviceCode_div').val("0000Z1999999");
		$('#serviceName_div').val("0000Z1999999");
		     return;
	}
		var dptCde = $.trim($('#deptCode_div').val());
		var channleCode_QD = $.trim($('#channelCodeQD').val());
		var newBsnsType = $.trim($('#newBsnsType').val());
		var empNo = $.trim($('#empNo_div').val());
		var agentNo = $.trim($('#agentNo_div').val());
		if (agentNo == ''){
			agentNo = $('#agentNo_select').val();
		}
	//必须先选择产品出单机构、归属渠道、业务来源、业务员代码、代理人代码，再获取
	if(dptCde.length==0){$.message('error',"请先选择出单机构");return;}
	if(empNo.length==0){$.message('error',"请先选择业务员代码");return;}

	$.openLoading();
	$.ajax({
		url : "<%=path%>/extend/queryServiceNo?"+new Date().getTime(),
		type : 'POST',
		async : true,
		data:{
			COMCODE:dptCde,
			BUSINESSSOURCE:newBsnsType,
			CHANNELNAME:channleCode_QD,
			USERCODE:empNo,
			AGENTCODE:agentNo
		},
		dataType:'json',
		success:function(result){
			$.closeLoading();
			if("success"!=result.result) {
				// serviceInfoWrite();
				$.message('error', "调用销管接口获取数据失败，请联系销管系统进行维护");
				return;
			}

			var select = document.getElementById("serviceCode_select");
			select.options.length = 0;
			select.add(new Option("-----请选择-----",""));
			servicenos_list = result.data;
			for (var i = 0; i < servicenos_list.length; i++) {
				var option = new Option();
				option.text = servicenos_list[i].SERVICENO + "-" + servicenos_list[i].SERVICENAME;
				option.title = servicenos_list[i].SERVICENO + "-" + servicenos_list[i].SERVICENAME;
				option.value = servicenos_list[i].SERVICENO;
				select.add(option);
			}
			serviceInfoSelect();
		}
	});
}

//服务代码可选状态
function serviceInfoSelect(){
	$('#serviceCode_select_div').css('display','inline').val("");
	$('#serviceCode_div').hide().val('');
	$('#serviceName_div').attr("readonly",true).css('background-color','#ccc').val("");
}
//团队代码可选状态
function teamInfoSelect(){
	$('#teamCode_select_div').css('display','inline').val("");
	$('#teamCode_div').hide().val('');
	$('#teamName_div').attr("readonly",true).css('background-color','#ccc').val("");
}

//关闭  窗口
function closeCurrentDIV(obj){
	if('deptDiv' == obj || 'subTradPartnerDiv' == obj){
		$("#"+obj).CloseDiv2();
	}else{
		$("#"+obj).CloseDiv();
	}
	divLevel="";
}

/*function changeType(){
	$("#prodSet").val("");
	var channelCode=$("#partnerCode_div").val();
	var key1=$("#pro_key1").val();
	var key2=$("#pro_key2").val();
	var key3=$("#pro_key3").val();
	var key4=$("#pro_key4").val();
	var key5=$("#pro_key5").val();
	var productType=$("#productType").val();
	$.ajax({
		url:"<%=path%>/extend/changeTypeId",
		type:'POST',
		async : true,
		data:{
			channelCode:channelCode,
			key1:key1,
			key2:key2,
			key3:key3,
			key4:key4,
			key5:key5,
			productType:productType
		},
		dataType:'json',
		success:function(data){
			$("#ishave").val(data.ishave);
			$("#agentInfoId").val(data.agentInfoId);
		}
	})
	if ($("#bsnsType").val() != '19001'){
		queryAgentAndAgreeInfo();

		$("#unauthorizedProducts_select").show();
	}else{
		$('#agentNo_select').empty();
		$('#agentNo_div').val('');
		$('#cbrkrname_div').val('');
		$('#protocolNo_div').val('');
		$('#PERMITNOB').val('');
		$("#unauthorizedProducts_select").hide();
		$('#agentNo_select').attr("disabled", true).css('background-color','#ccc');
		queryServiceNo();
	}
}*/
//新增广东销售信息配置20190516
function saleInfoConfig(){
	var id=$("#agentInfoId").val();
	var type=$("#productType").val();
	if(!type){
		$.message("error","请选择产品类型");
		return;
	}
		$.openLoading();
		$.ajax({
			url : "<%=path%>/extend/loadSale",
			type : 'POST',
			async : true,
			data:{
				id:id
			},
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if(data.success){
					rolemap.put("saleMenTypes", data.saleMenTypes);
					rolemap.put("saleTypes", data.saleTypes);
					rolemap.put("role", data.roleTypes);
					saleAgents = data.saleAgents;
					if(type==1 || type==2){
						createNlifeSale(saleAgents);
					}else{
						createNocarSale(saleAgents);
					}
				}else{
					$.message("error",data.message);
				}
			}
		});
	}


/**新意健险广东销售*/
function createNlifeSale(agents){
	var rowNum = 1;
	var newBsnsTypeText= $('#newBsnsType option:selected').text();
	if(newBsnsTypeText.indexOf("个人代理") != -1){rowNum = 2}
	var salecontent=''
		for (var i = 1; i <= rowNum; i++) {
			salecontent+='<tr id="yjx'+i+'">'+
			'<td>'+i+'<input type="hidden" id="nflag'+i+'" value="'+i+'"/></td>'+
			'<td>'+
				getSale4(i)+
			'</td>'+
			'<td><input type="text" id="nsaleMen'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
			'<td><input type="text" id="nsaleName'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>' +
			'<td><input type="text"  id="npermitNo'+i+'" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
			// '<td><input type="text"  id="nagentCode'+i+'" style=" width: 130px"/></td>'+
			// '<td><input type="text" id="nagentName'+i+'"  class="input_text" style=" width: 130px"/></td>'+
			'<td><input type="text" id="ncostRate'+i+'"  class="input_text" onkeyup="clearNoNum(event,this)" style=" width: 130px"/></td>'+
		'</tr>'
		}
	$('#salecontent4').html('');
	$('#salecontent4').html(salecontent);
	//赋值
	if(agents!=null){
		for (var i = 1; i <=agents.length; i++) {
			var o=agents[i-1];
			if(o&&o.planType==3){
			 $('#nflag'+o.seqNo).val(o.seqNo);
			 $('#npermitNo'+o.seqNo).val(o.practiceNo);
			 $('#nagentCode'+o.seqNo).val(o.agentCode);
			 $('#nagentName'+o.seqNo).val(o.agentName);
			 $('#nsaleMentype'+o.seqNo).val(o.personType);
			 $('#nsaleMen'+o.seqNo).val(o.empNo);
			 $('#nsaleName'+o.seqNo).val(o.saleName);
			 $('#ncostRate'+o.seqNo).val(parseFloat(o.agentFee).toFixed(2))
			}
		}
	}
	$("#nlifeSaleInfoDiv").OpenDiv();
}
function getSale4(i){
	var roles=rolemap.get("role");
	var hr='<select id="nsaleMentype'+i+'" class="select_1 valid" disabled="disabled" style=" width: 130px;background-color: #ccc">'
			+'<option value="">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
	return hr;
}
/**财险广东销售*/
function createNocarSale(agents){
	var rowNum = 1;
	var newBsnsTypeText= $('#newBsnsType option:selected').text();
	if(newBsnsTypeText.indexOf("个人代理") != -1){rowNum = 2}
	var salecontent=''
		for (var i = 1; i <=rowNum; i++) {
			salecontent+='<tr id="cx'+i+'">'+
			'<td>'+i+'<input type="hidden" id="flag'+i+'" value="'+i+'"/></td>'+
			'<td>'+
				getSale1(i)+
			'</td>'+
			'<td><input type="text" onkeyup="clearNoNum(event,this)"  id="saleRate'+i+'" style=" width: 130px"/></td>'+
			'<td><input type="text" id="saleCallNo'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
			'<td>'+
				getSale(i)+
				'</select>'+
			'</td>'+
			'<td><input type="text" id="saleMen'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
			'<td><input type="hidden" id="empNo'+i+'" />' +
			'<input type="text" id="agentName'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
			'<td><input type="text" id="agentNo'+i+'"  class="input_text" style=" width: 130px;background-color: #ccc" readonly="readonly"/></td>'+
		'</tr>'
		}
		$('#salecontent').html('');
		$('#salecontent').html(salecontent);
		//赋值
		if(agents!=null){
			for (var i = 1; i <=agents.length; i++) {
				var o=agents[i-1];
				if(o&&o.planType==2){
					 $('#flag'+o.seqNo).val(o.seqNo);
					 $('#saletype'+o.seqNo).val(o.saleType);
					 $('#saleRate'+o.seqNo).val(Number(o.agentFee));
					 $('#saleCallNo'+o.seqNo).val(o.practiceNo);
					 $('#saleMentype'+o.seqNo).val(o.personType);
					 $('#saleMen'+o.seqNo).val(o.salePerson);
					 $('#empNo'+o.seqNo).val(o.empNo);
					 $('#agentName'+o.seqNo).val(o.agentName);
					 $('#agentNo'+o.seqNo).val(o.agentNo)
				}
			}
		}
	$('#nocarSaleInfoDiv').OpenDiv()
}
function getSale(i){
	var roles=rolemap.get("saleMenTypes");
	var hr='<select id="saleMentype'+i+'" class="select_1 valid" disabled="disabled" style=" width: 130px;background-color: #ccc">'
			+'<option value="0">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
	return hr;
}
function getSale1(i){
	var roles=rolemap.get("saleTypes");
	var hr='<select id="saletype'+i+'" class="select_1 valid" disabled="disabled" style=" width: 130px;background-color: #ccc">'
			+'<option value="0">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
	return hr;
}
//销售人员信息保存
function  saveSale(){
	var type = $("#productType").val();
		arr1=[];
		arr=null;
	var proxyType = $('#newBsnsType option:selected').text();
	if(type==1 || type ==2){
		var salemap2=new Map();
		var salemap3=new Map();
		for (var i = 1; i <= 2; i++) {
			var flag=0;
			var j=0;
			var o=new Object();
			o.planType="3";
			//职业证号
			var seqNo=$('#nflag'+i).val();
			o.seqNo=seqNo;
			var permitNo=$('#npermitNo'+i).val();
			if($.trim(permitNo)!=''){
				o.practiceNo=permitNo;
				flag=flag+1;
			}
			//销售人员类别
			var saleType=$('#nsaleMentype'+i).val();
			var saleTypeName= $('#nsaleMentype'+i).find("option:selected").text();
			if(saleType!=''){
				o.personType=saleType;
				j=j+1;
				flag=flag+1;
			}
			//销售人员代码
			var saleMen=$('#nsaleMen'+i).val();
			if($.trim(saleMen)!=''){
				o.empNo=saleMen;
				j=j+1;
				flag=flag+1;
			}
			//销售人员名称
			var saleName=$('#nsaleName'+i).val();
			if($.trim(saleName)!=''){
				o.saleName=saleName;
				flag=flag+1;
			}
			//费用比例
			var costRate=$('#ncostRate'+i).val();
			if($.trim(costRate)!=''){
				o.agentFee=costRate;
				j++;
				flag=flag+1;
			}
			//代理人机构号
			var agentCode=$('#nagentCode'+i).val();
			if($.trim(agentCode)!=''){
				o.agentCode=agentCode;
				flag=flag+1;
			}
			//代理人机构名称
			var agentName=$('#nagentName'+i).val();
			if($.trim(agentName)!=''){
				o.agentName=agentName;
				flag=flag+1;
			}
			// if(j>=1&&j!=3){
			// 	$.message("error","新意健险销售信息配置序号为"+i+"的数据存在必填项未填写，请填写");
			// 	return;
			// }
			if($.trim(costRate)!=''){
				if(i!=1){
					var o1=salemap3.get(i-1);
					if(o1==null||o1==undefined||o1==false){
						$.message("error","新意健险销售信息配置序号为"+i+"的上一个序号未填写不能跳号");
						return;		
					}
				}
			}
			if($.trim(costRate)!=''){
				salemap3.put(i,o);
				arr1.push(o);
			}
		}
		var rate=0;
		for (var i = 1; i <= 2; i++) {
			if(salemap3.get(i).agentFee==''||salemap3.get(i).agentFee==undefined){
			}else{
				var rate1=salemap2.get(salemap3.get(i).personType);
				if(rate1){
					salemap2.put(salemap3.get(i).personType,parseFloat(salemap3.get(i).agentFee)+parseFloat(rate1));
				}else{
					salemap2.put(salemap3.get(i).personType,parseFloat(salemap3.get(i).agentFee));
				}
			}
		}
		var ncostRate1=$('#ncostRate1').val();
		if(ncostRate1 == null || ncostRate1 == ''){
			$.message("error","请填入手续费比例！");
			return;
		}
		var ncostRate2 = $('#ncostRate2').val();
		if(undefined == ncostRate2 ){ncostRate2 = 0}
		var allncostRate = parseFloat(ncostRate1) + parseFloat(ncostRate2) ;
		if(allncostRate!=1){
			$.message("error","新意健险销售信息配置相同人员分摊比例之和是1");
			return;
		}

		if(proxyType.indexOf("个人代理") != -1){
			var npermitNo2=$('#npermitNo2').val();
			if(npermitNo2 == null || npermitNo2 ==''){
				$.message("error", "执业证号不能为空，请返回上一页面重新配置代理人信息！！");
				return;
			}
		}
	}else{
		var salemap1=new Map();
		for (var i = 1; i <= 2; i++) {
			var flag=0;
			var j=0;
			var o=new Object();
			var seqNo=$('#flag'+i).val();
			o.seqNo=seqNo;
			o.planType="2";
			//销售人员类别
			var saletype=$('#saletype'+i).val();
			var saleName=$('#saletype'+i).find("option:selected").text()
			if(saletype!='0'){
				o.saleType=saletype;
				o.saleName=saleName;
				j=j+1;
				flag=flag+1;
			}
			//费用比例
			var saleRate=$('#saleRate'+i).val();
			if($.trim(saleRate)!=''){
				o.agentFee=saleRate;
				j=j+1;
				flag=flag+1;
			}
			//执业证号
			var saleCallNo=$('#saleCallNo'+i).val();
			if($.trim(saleCallNo)!=''){
				o.practiceNo=saleCallNo;
			}
			//人员类别
			var saleMentype=$('#saleMentype'+i).val();
			var saleMenName= $('#saleMentype'+i).find("option:selected").text();
			if(saleMentype!='0'){
				o.personType=saleMentype;
				o.personTypeName=saleMenName;
				flag=flag+1;
				j=j+1;
			}
			//销售人员
			var saleMen=$('#saleMen'+i).val();
			if($.trim(saleMen)!=''){
				o.salePerson=saleMen;
				flag=flag+1;
			}
			//业务员
			var empNo=$('#empNo'+i).val();
			if($.trim(empNo)!=''){
				o.empNo=empNo;
				flag=flag+1;
				j=j+1;
			}
			//业务员姓名
			var agentName=$('#agentName'+i).val();
			if($.trim(agentName)!=''){
				o.agentName=agentName;
			}
			//代理人编号
			var agentNo=$('#agentNo'+i).val();
			if($.trim(agentNo)!=''){
				o.agentNo=agentNo;
				flag=flag+1;
			}
			/*if(j>=1&&j!=4){
				$.message("error","财险销售信息配置序号为"+i+"的数据存在必填项未填写，请填写");
				return;
			}*/
			if($.trim(saleRate)!=''){
				if(i!=1){
					var o1=salemap1.get(i-1);
					/*if(o1==null||o1==undefined||o1==false){
						$.message("error","财险销售信息配置序号为"+i+"的上一个序号未填写不能跳号");
						return;
					}*/
				}
				salemap1.put(i,o);
				arr1.push(o);
			}
		}
		var saleRate1=$('#saleRate1').val();
		if(saleRate1 == null || saleRate1 == ''){
			$.message("error","请填入手续费比例！");
			return;
		}
		var rate=0;
		var isEmp=false;
		for (var i = 1; i <= 2; i++) {
			if(salemap1.get(i)){
				//比例校验 所有人员类别是业务员的比例之和是1，其他类别只能是0.
				if(salemap1.get(i).personType=='1'){
					if(salemap1.get(i).agentFee==''||salemap1.get(i).agentFee==undefined){
					}else{
						rate=parseFloat(rate)+parseFloat(salemap1.get(i).agentFee)
					}
					isEmp=true;
				}else{
					if(salemap1.get(i).agentFee!='0'){
						/*$.message("error","财险销售信息配置所有人员类别是业务员的比例之和是1，其他类别只能是0");
						salemap1.clear();
						return;*/
					}
				}
			}
		}
		var saleRate2=$('#saleRate2').val();
		if(undefined == saleRate2 ){saleRate2 = 0}
		var allSaleRate = parseFloat(saleRate1) + parseFloat(saleRate2) ;
		if(parseFloat(allSaleRate)!=1){
			$.message("error","财险销售信息配置所有人员类别是业务员的比例之和是1，其他类别只能是0");
			return;
		}
		if(proxyType.indexOf("个人代理") != -1){
			var saleCallNo2=$('#saleCallNo2').val();
			if(saleCallNo2 == null || saleCallNo2 ==''){
				$.message("error", "执业证号不能为空，请返回上一页面重新配置代理人信息！！");
				return;
			}
		}
	}
	 arr = JSON.stringify(arr1);
	 if("true" ==$("#ishave").val()){
			var id= $('#agentInfoId').val();
		 	$.ajax({
				url : "<%=path%>/extend/addTradSaleAgent",
				type : 'POST',
				async : true,
				data:{
					id:id,
					saleArry:arr
				},
				dataType:'json',
				success:function(result){
					$.closeLoading();
					if(result.result=='success'){
						closeCurrentDIV('nlifeSaleInfoDiv');
						closeCurrentDIV('nocarSaleInfoDiv');
						$.message("success", "添加成功");
					}else{
						$.message("error", "添加失败");
					}
				}
			});
	 }else{
		 $.message("success", "保存成功");
	 }
	closeCurrentDIV('nlifeSaleInfoDiv');
	closeCurrentDIV('nocarSaleInfoDiv');

}
var unauthorized_prodList ;//销管未授权产品集合
//查询并展示未授权产品集合
	function queryUnauthorizedProducts(){
		$("#unauthorizedProducts").empty();
		var COMCODE =  $.trim($('#deptCode_div').val());
		var productType =  $.trim($('#productType').val());
		var agentCode = $("#agentNo_select").val();
		var prodSaleCode = 'A225';//1949产品销管代码
		var channleCode_QD = $.trim($('#channelCodeQD').val());
		var newBsnsType =$.trim($('#newBsnsType').val());
		var teamCode = $.trim($('#teamCode_div').val());
		var empNo = $('#empNo_select').val();
		if (empNo == ''){
			empNo = $('empNo_div').val();
		}
		$.ajax({
			url : "extend/queryUnauthorizedProducts",
			type : "POST",
			async : false,
			data : {
				COMCODE:COMCODE,
				productType:productType,
				agentCode:agentCode,
				TEAMCODE:teamCode,
				BUSINESSSOURCE:newBsnsType,
				CHANNELNAME:channleCode_QD,
				PRODCODE:prodSaleCode,
				empNo:empNo
			},
			dataType : "json",
			success:function(Result){
				var select = document.getElementById("unauthorizedProducts");
				unauthorized_prodList = Result.data["PRODCODEList"];
				$("#prodSet").val(Result.data["prodlist"]);
				for (var i = 0; i < unauthorized_prodList.length; i++) {
					var option = new Option();
					option.text = unauthorized_prodList[i];
					option.title = unauthorized_prodList[i];
					option.value = unauthorized_prodList[i];
					select.add(option);
				}
			}
		});
	}

	function queryHistorySaleInfo() {
		var productType="";
		var prod = document.getElementsByName("prodtype");
		for(var i=0;i<prod.length;i++){
			if(prod[i].checked){
				productType = prod[i].value
			}
		}
		if(null == productType || "" == productType){
			$.message("error","请选择产品类型");
			return;
		}
		var channelCode=$("#partnerCode_div").val();
		var key1=$("#pro_key1").val();
		var key2=$("#pro_key2").val();
		var key3=$("#pro_key3").val();
		var key4=$("#pro_key4").val();
		var key5=$("#pro_key5").val();
		window.location.href = "<%=path%>/extend/recallAgentInfo?key1="+key1+"&key2="+key2+"&key3="+key3+"&key4="+key4+"&key5="+key5+"&productType="+productType+"&channelCode="+channelCode;
    }
	//查询广东销售信息
	function querySalesInfo(){
		var COMCODE = $("#deptCode_div").val();
		var USERNAME = $("#empName_div").val();
		var TEAMCODE = $("#teamCode_div").val();
		var USERCODE = $("#empNo_div").val();
		$.ajax({
			url : "extend/querySalesInfo",
			type : "POST",
			async : false,
			data : {
				COMCODE:COMCODE,
				USERNAME:USERNAME,
				TEAMCODE:TEAMCODE,
				USERCODE:USERCODE
			},
			dataType : "json",
			success:function(Result){
				if(Result.data == null){
					$.message("error","未查询到销售员信息！");
					return ;
				}
				var PERSONTYPE = Result.data["PERSONTYPE"];
				var USERCODE = Result.data["USERCODE"];
				var USERNAME = Result.data["USERNAME"];
				var PERMITNO = Result.data["PERMITNO"];
				var LEADERFLAG = Result.data["LEADERFLAG"];
				var newBsnsTypeText= $('#newBsnsType option:selected').text();
				var prodType = $('#productType').val();
				var cbrkrname_div = $('#cbrkrname_div').val();
				var agentNo_div = $('#agentNo_div').val();
				var PERMITNOB = $('#PERMITNOB').val();
				var empNo_div = $('#empNo_div').val();//业务员
				if(prodType == "1"){   //意健险
					if(newBsnsTypeText.indexOf("直销业务") != -1 || newBsnsTypeText.indexOf("兼业代理") != -1){
						console.log("意健险直销业务");
						$('#nsaleMentype1').val('0'+PERSONTYPE);
						$('#nsaleMen1').val(USERCODE);
						$('#nsaleName1').val(USERNAME);
						$('#npermitNo1').val(PERMITNO);
					}
					if(newBsnsTypeText.indexOf("个人代理") != -1){
						console.log("意健险个人代理");
						$('#nsaleMentype1').val('0'+PERSONTYPE);
						$('#nsaleMen1').val(USERCODE);
						$('#nsaleName1').val(USERNAME);
						$('#npermitNo1').val(PERMITNO);
						$('#nsaleMentype2').val('02');
						$('#nsaleMen2').val(agentNo_div);
						$('#nsaleName2').val(cbrkrname_div);
						$('#npermitNo2').val(PERMITNOB);
					}
					if(newBsnsTypeText.indexOf("专业代理") != -1 || newBsnsTypeText.indexOf("经纪业务") != -1){
						//判断基础业务员是否为团队长
						if(LEADERFLAG == "0"){//非团队长
							$('#nsaleMentype1').val('0'+PERSONTYPE);
							$('#nsaleMen1').val(USERCODE);
							$('#nsaleName1').val(USERNAME);
							$('#npermitNo1').val(PERMITNO);
						}else{
							$('#nsaleMentype1').attr("disabled",false).css("background-color","white");
							$('#nsaleMen1').attr("readOnly",false).css("background-color","white");
							$('#nsaleName1').attr("readOnly",false).css("background-color","white");
							$('#npermitNo1').attr("readOnly",false).css("background-color","white");
						}
					}
				}
				if(prodType == "3" || prodType == "4"){  //财险、责任险
					if(newBsnsTypeText.indexOf("直销业务") != -1 || newBsnsTypeText.indexOf("兼业代理") != -1){
						console.log("财险直销业务");
						$('#saleMentype1').val(PERSONTYPE);
						$('#empNo1').val(USERCODE);
						$('#agentName1').val(USERNAME);
						$('#saleCallNo1').val(PERMITNO);
						$('#saletype1').val("1");
					}
					if(newBsnsTypeText.indexOf("个人代理") != -1){
						console.log("财险个人代理");
						$('#saleMentype1').val(PERSONTYPE);
						$('#empNo1').val(USERCODE);
						$('#agentName1').val(USERNAME);
						$('#saleCallNo1').val(PERMITNO);
						$('#saletype1').val("1");
						$('#saletype2').val("1");
						$('#saleCallNo2').val(PERMITNOB);
						$('#saleMentype2').val('7');
						$('#saleMen2').val(cbrkrname_div);
						$('#agentNo2').val(agentNo_div);
						$('#empNo2').val(empNo_div);
					}
					if(newBsnsTypeText.indexOf("专业代理") != -1 || newBsnsTypeText.indexOf("经纪业务") != -1){
						//判断基础业务员是否为团队长
						if(LEADERFLAG == "0"){//非团队长
							$('#saleMentype1').val(PERSONTYPE);
							$('#empNo1').val(USERCODE);
							$('#agentName1').val(USERNAME);
							$('#saleCallNo1').val(PERMITNO);
							$('#saletype1').val("1");
						}else{
							$('#saleCallNo1').attr("readOnly",false).css("background-color","white");
							$('#saleMen1').attr("readOnly",false).css("background-color","white");
							$('#saletype1').val("2");
						}
					}
				}
			}
		});
	}
	//清除下拉框选项
function removeOptions(id) {
		var element = document.getElementById(id);
		element.options.length=0;
		$("<option value=''>----请选择----</option>").appendTo(element);
}
//页面加载时选择产品类型
function chooseProdType(){
   $("#chooseProdTypeDiv").OpenDiv();
}
function confirmProdType(prodType) {
	closeCurrentDIV('chooseProdTypeDiv');
	var key1 = $("#pro_key1").val();
	var key2 = $("#pro_key2").val();
	var key3 = $("#pro_key3").val();
	var key4 = $("#pro_key4").val();
	var key5 = $("#pro_key5").val();
	var channelCode = $("#partnerCode_div").val();
	$.ajax({
		url: "extend/queryAgentInfoByProdType",
		type: "POST",
		async: false,
		data: {
			key1: key1,
			key2: key2,
			key3: key3,
			key4: key4,
			key5: key5,
			productType: prodType,
			channelCode: channelCode
		},
		dataType: "json",
		success: function (data) {
			var ishave = data["ishave"];
			var saleInfo = data["info"];
			var prodType = data["prodType"];
			$("#productType").find("option[value="+prodType+"]").attr("selected",true);
			var channelType = saleInfo.channleType ;
			var newBsnsType = saleInfo.newBsnsType ;
			var channelList = data["channelList"];
			var newBSList = data["newBSList"];
			var select1 = document.getElementById("channelType");
			var select2 = document.getElementById("newBsnsType");
			for (let i = 0; i < channelList.length; i++) {
				var option = new Option();
				option.text = channelList[i].codeName;
				option.value = channelList[i].code;
				select1.add(option);
				}
			for (let i = 0; i < newBSList.length; i++) {
				var option = new Option();
				option.text = newBSList[i].codeName;
				option.value = newBSList[i].code;
				select2.add(option);
			}
			if(ishave){
				//如果已经存在该销售信息，进行页面回显
				$("#deptCode_div").val(saleInfo.dptCde);
				$("#agentInfoId").val(saleInfo.id);
				$("#empNo_select_div").css("display","none");
				$("#empNo_div").css("display","inline").val(saleInfo.empNo);
				$("#empName_div").val(saleInfo.empName);
				$("#teamCode_select_div").css("display","none");
				$("#teamCode_div").val(saleInfo.teamCode);
				$("#teamName_div").val(saleInfo.teamName);
				$("#channelCodeQD").val(saleInfo.channleCode);
				$("#channelType").find("option[value="+channelType+"]").attr("selected",true);
				$("#newBsnsType").find("option[value="+newBsnsType+"]").attr("selected",true);
				$("#bsnsType").val(saleInfo.categoryCode);
				$("#agentNo_select_div").css("display","none");
				$("#agentNo_div").val(saleInfo.agentNo);
				$("#protocolNo_div").val(saleInfo.protocolNo);
				$("#cbrkrname_div").val(saleInfo.cbrkrname);
				$("#serviceCode_select_div").css("display","none");
				$("#serviceCode_div").val(saleInfo.serviceCode);
				$("#serviceName_div").val(saleInfo.serviceName);

				$.dialog({
					type: "warn",
					content: "合作伙伴已存在该销售信息,是否需要修改？",
					onOk: function() {
						$("#empNo_select_div").css("display","inline");
						$("#empNo_div").css("display","none")
						//清空所有信息
						$('#empNo_select').val("");
						$('#empName_div').val("");
						$('#teamCode_div').val("");
						$('#teamName_div').val("");
						$('#channelCodeQD').val("");
						removeOptions("channelType");
						removeOptions("newBsnsType");
						$('#agentNo_div').val("");
						$('#protocolNo_div').val("");
						$('#cbrkrname_div').val("");
						$('#protocolNo_div').val("");
						$('#serviceCode_div').val("");
						$('#serviceName_div').val("");
						$('#bsnsType').val("");
					},
					onCancel:function(){
						$('#empNo_select').attr('disabled','disabled').css('background-color','#ccc')
						$('#teamCode_select').attr('disabled','disabled').css('background-color','#ccc')
						$('#channelType').attr('disabled','disabled').css('background-color','#ccc')
						$('#newBsnsType').attr('disabled','disabled').css('background-color','#ccc')
						$('#channelCodeQD').attr('disabled','disabled').css('background-color','#ccc')
					}
				});
			}else{
				//新增销售信息
			}
		}
	})

}
</script>
</head>

<body>
<input id="prodSet" type="hidden" value=""/>
<input id="PERMITNOB" type="hidden" value="${info.cAgentSlsCde}"/>
<input id="realChannels" type="hidden" value=""/>
<table class="table_05">
      <tbody>
            <tr>
             <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">
          		极速出单销售管理配置&nbsp;&nbsp;&nbsp;<input type="button" value="广东销售信息配置" onclick="saleInfoConfig()" id="saleInfoConfigId">
          	</td>
	      </tr>
			<tr>
				<h3 style="color: red">配置步骤：1、选择出单机构---->2、选择业务员代码---->3、选择团队代码---->4、选择渠道类型---->5、选择对应产品类型---->6、选择代理人编码（非直销）---->7、选择服务代码</h3>
			</tr>
			<tr>
				<h3 style="color: #0000FF">数据经销管系统查询，不能手动录入，如无法获取，请联系销管系统进行维护</h3>
			</tr>
	    <tr>
         <th width="10%">销售类型：</th>
         <td width="40%">
			<input  class="input_text" value='联合出单代理' readonly="readonly" style=" background-color: #ccc;">
			<input id="agentType_div" type="hidden" value="5">
			<input id="ishave" value="${ishave}" type="hidden" >
			<input id="agentInfoId" value="${info.id}" type="hidden" >
         </td>
         <th width="10%">合作伙伴：</th>
         <td width="40%"><input id="partnerCode_div"  id="partnerCode_div" class="input_text" value='JSCD' readonly="readonly" style=" background-color: #ccc;"><span class="red">*</span></td>
     	</tr>
     	 <tr>
			 <th width="10%">出单机构：</th>
			 <td width="40%">
				 <input id="deptCode_div"  type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text" value="${info.dptCde }"><span class="red">*</span>&nbsp;<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv(1,this)"/>
			 </td>
			 <th></th>
			 <td></td>
     	</tr>
     	<tr>
			<th width="10%">业务员代码：</th>
			<td width="40%">
				<div id="empNo_select_div" style="display: none">
					<select id="empNo_select" onchange="changeEmpNo()" class="select_1"></select>
				</div>
				<input id="empNo_div" name="empNo_div" readonly="readonly" style="background-color: #CCC"  type="text" maxlength="10" class="input_text" value="${info.empNo }"/><span class="red">*</span>
			</td>
			<th width="10%">业务员名称：</th>
			<td width="40%">
				<input id="empName_div" name="empName_div" readonly="readonly" style="background-color: #CCC"  type="text" maxlength="20" class="input_text" value="${info.empName }"/><span class="red">*</span>
			</td>
     	</tr>
     	<tr>
			<th width="10%">团队代码：</th>
			<td width="40%">
				<div id="teamCode_select_div" style="display: none" >
					<select id="teamCode_select" onchange="changeTeamCode()" class="select_1"></select>
				</div>
				<input id="teamCode_div"  name="teamCode_div"  readonly="readonly" style="background-color: #CCC" type="text" maxlength="11" class="input_text" value="${info.teamCode}"/><span class="red">*</span>
			</td>
			<th width="10%">团队名称：</th>
			<td width="40%">
				<input id="teamName_div" name="teamName_div"  readonly="readonly" style="background-color: #CCC" type="text" maxlength="300" class="input_text" value="${info.teamName }"/><span class="red">*</span>
			</td>
     	</tr>
     	<tr>
			<th width="10%">渠道类型：</th>
			<td width="40%">
				<select id="channelType" class="select_1 valid" style="visibility: visible;">
					<option value="">-----请选择渠道类型-----</option>
					<c:forEach var ="channelList" items="${channelList}">
						<option value="${channelList.code}"<c:if test="${channelList.code==info.channleType }">selected="selected"</c:if>>${channelList.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<th width="10%">归属渠道：</th>
			<td width="40%">
				<select id="channelCodeQD" class="select_1 valid"  disabled="disabled">
					<option value="">-----请选择-----</option>
					<c:forEach var ="btcList" items="${btcList}">
						<option value="${btcList.code}"<c:if test="${btcList.code==info.channleCode }">selected="selected"</c:if>>${btcList.codeName}</option>
					</c:forEach>
				</select>
			</td>
     	</tr>
     	<tr>
			<th width="10%">新业务来源：</th>
			<td width="40%">
				<select id="newBsnsType" class="select_1 valid" style="visibility: visible;"">
				<option value="">-----请选择-----</option>
				<c:forEach var ="newBSList" items="${newBSList}">
					<option value="${newBSList.code}"<c:if test="${newBSList.code==info.newBsnsType }">selected="selected"</c:if>>${newBSList.codeName}</option>
				</c:forEach>
				</select>
			</td>
			<th width="10%">原业务来源：</th>
			<td width="40%">
				<select id="bsnsType" class="select_1 valid" disabled="disabled" style="visibility: visible;background-color: #ccc;">
					<option value="">-----请选择-----</option>
					<c:forEach var ="oldBSList" items="${oldBSList}">
						<option value="${oldBSList.code}"<c:if test="${oldBSList.code==info.categoryCode }">selected="selected"</c:if>>${oldBSList.codeName}</option>
					</c:forEach>
				</select>
			</td>
     	</tr>
     	<tr>
			<th width="10%">代理人编码：</th>
			<td width="40%">
				<div id="agentNo_select_div" style="display: none">
					<select id="agentNo_select" onchange="changeAgentNo()" class="select_1"></select>
				</div>
				<input id="agentNo_div" name="agentNo_div" type="text" maxlength="20" readonly="readonly" style="background-color: #CCC" class="input_text" value="${info.agentNo }"/><span class="red">*</span>
			</td>
	        <th width="10%">代理人协议号：</th>
	        <td width="40%">
					<input id="protocolNo_div" name="protocolNo_div"  readonly="readonly" style="background-color: #CCC" type="text" maxlength="13" class="input_text" value="${info.protocolNo }"/><span class="red">*</span>
	        </td>
     	</tr>
     	<tr>
			<th width="10%"></th>
			<td width="40%">
			<th width="10%">代理人名称：</th>
			<td width="40%">
				<input id="cbrkrname_div" name="cbrkrname_div"  readonly="readonly" style="background-color: #CCC" type="text" maxlength="20" class="input_text" value="${info.cbrkrname }"/><span class="red">*</span>
			</td>
     	</tr>
			<tr>
				<th width="10%">服务代码：</th>
				<td width="40%">
					<div id="serviceCode_select_div" style="display: none">
						<select id="serviceCode_select" onchange="changeServiceCode()" class="select_1"></select>
					</div>
					<input id="serviceCode_div" name="serviceCode_div" readonly="readonly" type="text" maxlength="20" class="input_text" style="background-color: #CCC" value="${info.serviceCode }"/><span class="red">*</span>
				</td>
				<th width="10%">服务名称：</th>
				<td width="40%">
					<input id="serviceName_div" name="serviceName_div" readonly="readonly" type="text" maxlength="20" class="input_text" style="background-color: #CCC" value="${info.serviceName }"/><span class="red">*</span>
				</td>
			</tr>
     	<tr>
			<th width="10%">Key1：</th>
			<td width="40%">
				<input id="pro_key1" name="pro_key1" type="text" maxlength="300" class="input_text" value="${info.key1 }"readonly="readonly" style=" background-color: #ccc;"/><span class="red">*</span>车险出单机构
			</td>
	        <th width="10%">Key2：</th>
	        <td width="40%">
					<input id="pro_key2" name="pro_key2" type="text" maxlength="300" class="input_text" value="${info.key2 }"readonly="readonly" style=" background-color: #ccc;"/><span class="red">*</span>车险业务员代码
	        </td>
     	</tr>
     	<tr>
			<th width="10%">Key3：</th>
			<td width="40%">
				<input id="pro_key3" name="pro_key3" type="text" maxlength="300" class="input_text" value="${info.key3 }"readonly="readonly" style=" background-color: #ccc;"/>&nbsp;车险服务代码
			</td>
	        <th width="10%">Key4：</th>
	        <td width="40%">
					<input id="pro_key4" name="pro_key4" type="text" maxlength="300" class="input_text" value="${info.key4 }"readonly="readonly" style=" background-color: #ccc;"/>&nbsp;车险代理协议号
	        </td>
     	</tr>
		<tr>
			<th width="10%">Key5：</th>
			<td width="40%">
				<input id="pro_key5" name="pro_key5" type="text" maxlength="300" class="input_text" value="${info.key5 }"readonly="readonly" style=" background-color: #ccc;"/>&nbsp;车险新业务来源
			</td>
			<th width="10%">销售落地数据对应的产品类型</th>
			<td width="40%">
				<select id="productType" class="select_1 valid" style="visibility: visible;background-color: #ccc;" disabled="disabled">
					<option value="">-----请选择-----</option>
					<option value="1" <c:if test="${info.productType == '1'}">selected="selected"</c:if>>意外/健康险</option>
					<option value="3" <c:if test="${info.productType == '3'}">selected="selected"</c:if>>财产险</option>
					<option value="4" <c:if test="${info.productType == '4'}">selected="selected"</c:if>>责任险</option>
				</select><span class="red">*</span>
			</td>
		</tr>
	    <tr id="unauthorizedProducts_select">
		  <th width="10%">未授权四位产品清单</th>
			<td width="40%">
				<div id="unauthorizedProducts_div" >
					<select id="unauthorizedProducts" class="select_1 valid" style="visibility: visible;background-color: white;"/>
				</div>
				<input id="" name="" readonly="readonly" style="background-color: #CCC;display: none"  type="text" maxlength="10" class="input_text" value=""/><span class="red">代理协议中未配置的产品</span>
			</td>
	    </tr>
<%--			<tr id="showHistoryInfo">--%>
<%--				<th width="10%">回显配置好的历史销售信息</th>--%>
<%--				<td width="40%">--%>
<%--					<span>意健险</span><input type="radio" name="prodtype" value="1"/>--%>
<%--					<span>财险</span><input type="radio" name="prodtype" value="3"/>--%>
<%--					<span>责任险</span><input type="radio" name="prodtype" value="4"/>--%>
<%--					<input type="button"  class="input_button_3" id="queryHistoryData" value="查询" onClick="queryHistorySaleInfo()"--%>
<%--						   />--%>
<%--					<span style="color: red">配置信息时无需选择，只用于查询之前配置好的信息</span>--%>
<%--				</td>--%>
<%--			</tr>--%>
 	 </tbody>
</table>
   <div align="center">
         <input class="input_button_3" id="saveNlifePlanBtn" type="button" onclick="saveAgentMtInfo()" value="保存">&nbsp;&nbsp;
	</div>
	<!-- 出单机构div -->
	<div id="deptDiv" style="display:none;width:50%;">
  		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('deptDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 出单机构代码：<input name="txt3"  id="deptcode"  type="text" class="input_text" value="" >&nbsp;&nbsp;
							 出单机构名称：<input name="txt3" id="deptcnname"  type="text" class="input_text" value="">
								       <input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryCoreDept(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="deptTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:45%">出单机构代码</th>
			                  <th style="width:50%">出单机构名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="deptPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="确定" onclick="chooseDept()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('deptDiv')" class="input_button_3"/>
		</div>
	</div>
	<!-- 出单机构div结束 -->
	<!-- 广东销售信息配置 -->
	<div id="nlifeSaleInfoDiv" style="display:none;width:1000px; height:280px;">
			<div class="table_title_div">
					<table class="table_title" style='width:100%;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('nlifeSaleInfoDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:0px;" align="center">
			<tr>
				<td>
					<table id="saleConfigTable" >
						<thead>
							<tr class="f1">
			                  <th style="width:5%">序号</th>
			                  <th style="width:10%">销售员类别<span class="red">*</span></th>
			                  <th style="width:10%">销售人员代码<span class="red">*</span></th>
			                  <th style="width:10%">销售人员名称</th>
			                  <th style="width:10%">执业证号</th>
<%--			                  <th style="width:10%">代理机构号</th>--%>
<%--			                  <th style="width:10%">代理人机构名称</th>--%>
			                  <th style="width:10%">分摊比例<span class="red">*</span></th>
			              	</tr>
						</thead>
						<tbody	id="salecontent4">
						</tbody>
					</table>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="querySalesInfo" value="查询" onclick="querySalesInfo()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" id="saveRoleBtn" value="确定" onclick="saveSale()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('nlifeSaleInfoDiv')" class="input_button_3"/>
		</div>
	</div>
<!--广东分公司配置销售人员信息div-->
  	<div id="nocarSaleInfoDiv" style="display:none;width:1000px; height:450px;">
		<div class="table_title_div">
					<table class="table_title" style='width:100%;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('nocarSaleInfoDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="width:990px;" align="center">
			<tr>
				<td>
					<table id="sale3" ">
						<thead>
							<tr class="f1">
			               	  <th style="width:90px">序号</th>
			                  <th style="width:110px">销售员类型<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">费用比例<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">执业证号</th>
			                  <th style="width:90px">人员类别<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">销售员</th>
			                  <th style="width:90px">业务员<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">代理人编号</th>
			              	</tr>
						</thead>
						<tbody id='salecontent'>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="queryNocarSalesInfo" value="查询" onclick="querySalesInfo()" class="input_button_3"/>&nbsp;
		  <input type="button" id="saveRoleBtn" value="确定" onclick="saveSale()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('nocarSaleInfoDiv')" class="input_button_3"/>
		</div>
	</div>
	<div id="chooseProdTypeDiv"  style="width: 18%;height: 24%;margin: auto;margin-top: 0;margin-left: -6%; background-color: #3cabd3;display: none">
		<div style="padding: 4%"> <h3>请选择要配置的产品类型:</h3></div>
		<div style="margin-bottom: 4%;margin-top: 4%;margin-left: 8%"><input type="button"  class="input_button_2"  value="意外/健康险" onClick="confirmProdType(1)"/></div>
		<div style="margin-left: 8%"><input type="button"  class="input_button_2"  value="财险" onClick="confirmProdType(3)"/></div>
		<div style="margin-top: 4%;margin-left: 8%"> <input type="button"  class="input_button_2"  value="责任险" onClick="confirmProdType(4)"/></div>
	</div>
</body>
</html>